function send(res,code,message){
	res.status(200).json({code,message})
}

//判断cookie是否存在
function signIn(req,res,next){
	var name = req.cookies.username
	if(name){
		next()
	}else{
		if(req.xhr){
			send(res,'fail','对不起，请先登录...')
		}else{
			res.direct('/')
		}
	}
}


module.exports = {
	send,
	signIn
}